package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shop.pojo.Goods;
import com.example.shop.pojo.UserBrowseHistory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserBrowseHistoryMapper extends BaseMapper<UserBrowseHistory> {
    @Select("select * from r_user_browse_history where user_id=#{userId}")
    List<UserBrowseHistory> selectByUserId(@Param("userId") Long userId);

    @Insert("insert into r_user_browse_history(user_id,goods_id,browse_date) " +
            "VALUES(${browseHistory.userId},${browseHistory.goodsId},#{browseHistory.browseDate}) " +
            "ON DUPLICATE KEY UPDATE " +
            "browse_date = #{browseHistory.browseDate}")
    int noExInsOrUp(@Param("browseHistory") UserBrowseHistory browseHistory);


    @Delete("delete from r_user_browse_history where user_id = ${userId} and goods_id = ${goodsId}")
    int delete(@Param("userId") long userId,@Param("goodsId") long goodsId);
}
